package com.kgc.scd.controller;

import com.kgc.scd.annotation.RequestPermission;
import com.kgc.scd.service.SubmitOrderService;
import com.kgc.scd.util.RequestResult;
import com.kgc.scd.util.ResultBuildUtil;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.xml.crypto.dsig.keyinfo.RetrievalMethod;
import java.util.List;
import java.util.Map;

/**
 * Created On : 2022/6/20.
 * <p>
 * Author     : 98730
 * <p>
 * Description: SubmitOrderController
 */
@Slf4j
@Api(tags = "18、购物车提交订单")
@RestController
public class SubmitOrderController {

    @Autowired
    private SubmitOrderService submitOrderService;

    /**
     * @author : 98730
     * @date   : 2022/6/14
     * @param  : [java.util.List<java.lang.Integer>]
     * @return : java.util.List<com.kgc.scd.bean.OrderItemResult>
     * @description : 添加订单/订单项，返回订单集合
     */
    @PostMapping("/orderItemResultListFeign")
    @RequestPermission
    @ApiOperation(value = "提交订单", notes = "根据用户选择的购物车内容进行提交订单操作")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cartIds", value = "购物车编号")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "SUCCESS"),
            @ApiResponse(code = 500, message = "FAIL")
    })
    RequestResult<Map<String, String>> orderItemResultListFeign(@RequestParam("cartIds") List<Integer> cartIds) {
       return submitOrderService.orderItemResultList(cartIds);
    }
}
